<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
<include file="Public:header" />
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerToolBar.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
    
 
    <script type="text/javascript">
         var grid,mydialog;
        $(function ()
        {
            //工具栏按钮
            var toolbarOptions = {
            		 items: [
            		   <volist id="item" name="button" >
                  	       <neq name="item['name']|strtolower" value="public" >
                  	             <neq name="item['name']|strtolower" value="index" >
                  	                  <eq name="item['access']" value="1" >
                  	                      { text:"{$item['title']}",id:"{$item['name']}", click:toolbarBtnItemClick, img: "__ROOT__{$item['nodeicon']}" },{ line: true },
                  	                  </eq>
                  	             </neq>
                  	       </neq>
                  	  </volist>
                  	{ line: true } 
               ]
            };
             grid=$("#maingrid").ligerGrid({
                columns: [
				{ display: '编号', name: 'id', align: 'left', width: 50, minWidth: 60 },
                { display: '名称', name: 'name', align: 'left', width: 100, minWidth: 60 },
                { display: '创建日期', name: 'create_time', minWidth: 140,render:function (rowdata, rowindex, value){return DateFormat(value,"yyyy-mm-dd ");} },
                { display: '状态', name: 'status',render:function (row){return (row.status ==true)?'<img src="__PUBLIC__/lib/ligerui/skins/icons/ok.gif">':'<img src="__PUBLIC__/lib/ligerui/skins/icons/lock.gif">'; }},
                { display: '操作', isSort: false, width: 120, render: function (rowdata, rowindex, value){
                    var h = "";
                    if (rowdata.status=="1"){
                    	 h += "<a href='javascript:forbid(" + rowdata.id + ")'>禁用</a> ";
                    }
                    else{
                    	h += "<a href='javascript:resume(" + rowdata.id + ")'>恢复</a> ";
                    }
                    
                        h += "<a href='javascript: grant(" + rowdata.id + ")'>授权</a> ";
                        h += "<a href='javascript: user(" + rowdata.id + ")'>用户列表</a> ";
                    return h;
               }}
                ], 
                url:'__URL__/getlist',  pageSize:30 ,rownumbers:true,height:'100%',checkbox:false,
                toolbar:toolbarOptions
            });
            $("#pageloading").hide();
        });
       
        
        //工具条事件
        function toolbarBtnItemClick(item) {
            switch (item.id) {
                case "add":
                	mydialog=$.ligerDialog.open({ url: '__URL__/add/id/0', height: 500, width: 700,
                      	buttons: [{ text: '确定', onclick: function (item, dialog) {save(dialog); } },
                                    { text: '取消', onclick: function (item, dialog) { dialog.close(); } }],
                                    isResize: true,isHidden:false
                   });
                    break;
                case "edit":
                	var selected = grid.getSelected();
                    if (!selected) { $.ligerDialog.warn('请选择行!'); return }
                    mydialog=$.ligerDialog.open({ url: '__URL__/edit/id/'+selected.id, height: 500, width: 700,
                    	buttons: [{ text: '确定', onclick: function (item, dialog) {save(dialog);  } },
                                  { text: '取消', onclick: function (item, dialog) { dialog.close(); } }],
                                  isResize: true,isHidden:false
                 });
                    break;
                case "del":
                    jQuery.ligerDialog.confirm('确定删除吗?', function (confirm) {
                        if (confirm)
                    del();
                    });
                    break;
                default:{
                	LG.tip("此方法没有定义,联系管理员设定按钮权限!");
                }
            }
        }
        
        function save(dialog)
        {
        	var fn = dialog.frame.f_save();//subset || dialog.frame.window.f_subset; 
        		

        }
        function forbid(id){
           	$.post("__URL__/forbid/",{"id":id}, function(data){
               	 	grid.loadData();
     		 	//	$.ligerDialog.alert(data);//
     		 		var m= $.ligerDialog.tip({  title: '提示信息',content:data });
     		 		setTimeout(function (){m.close();}, 1000);

			});
        }
        function resume(cid){
        	$.post("__URL__/resume/", {"id":cid},function(data){
                grid.loadData();
     		   var m=$.ligerDialog.tip({  title: '提示信息',content:data });
     		   setTimeout(function (){m.close();}, 1000);

			});
        }
        function  grant(id){
            $.ligerDialog.open({ url: '__URL__/grant/groupId/'+id, title:'授权窗口',height: 600, width: 500,
            	buttons: [{ text: '确定', onclick: function (item, dialog) { dialog.close(); } },
                          { text: '取消', onclick: function (item, dialog) { dialog.close(); } }],
                          isResize: true,isHidden:false
         });
        }
        function  user(id){
            $.ligerDialog.open({ url: '__URL__/user/id/'+id, title:'用户列表',height: 500, width: 300,
            	buttons: [{ text: '确定', onclick: function (item, dialog) { dialog.close(); } },
                          { text: '取消', onclick: function (item, dialog) { dialog.close(); } }],
                          isResize: true,isHidden:false
         });
        }
    </script>
</head>
<body style="overflow-x:hidden; padding:2px;">
<div class="l-loading" style="display:block" id="pageloading"></div>
 <div class="l-clear"></div>
    <div id="maingrid"></div>
  <div style="display:none;">
</div>
 
</body>
</html>
